package com.yefcion.andcode;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author: yefcion.github.io
 */
public class MainActivity extends BasicActivity {

    @BindView(R.id.btn_jack)
    Button mBtnJack;
    @BindView(R.id.btn_close)
    Button mBtnClose;
    @BindView(R.id.btn_jump)
    Button mBtnJump;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
        // todo x 隐藏当前Activity的标题，暂未生效
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.menu_item_add:
                Toast.makeText(this, "Click oon menu add", Toast.LENGTH_SHORT).show();
                break;
            case R.id.menu_item_remove:
                Toast.makeText(this, "Click on menu remove", Toast.LENGTH_SHORT).show();
                break;
            default:
                break;
        }
        return true;
    }

    @OnClick({R.id.btn_jack, R.id.btn_close, R.id.btn_jump})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn_jack:
                toastShort("Click on the Jack");
                break;
            case R.id.btn_close:
                finish();
                break;
            case R.id.btn_jump:
                SecondActivity.start(MainActivity.this);
                break;
            default:
        }
    }

    private void toastShort(String toast) {
        Toast.makeText(MainActivity.this, toast, Toast.LENGTH_SHORT).show();
    }
}
